﻿using SD.DALFactory;
using SD.DataAccess.Repository;
using SD.Entity;
using SD.Entity.PageSearch;
using SD.Entity.SearchEntity;
using SD.Interface.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SD.Business.Service
{
    public class UserInfoService : IUserInfoService
    {
        private UserInfoRepository userInfoRepository;
        public UserInfoService()
        {
            userInfoRepository = AbstractFactory.CreateUserInfoRepository();
        }

        public UserInfo GetUserInfo(int Id)
        {
            return userInfoRepository.GetUserInfo(Id);
        }

        public int DeleteUserInfo(int Id)
        {
            return userInfoRepository.DeleteUserInfo(Id);
        }

        public int SaveUserInfo(UserInfo userInfo)
        {
            if (userInfo.Id <= 0)
            {
                return (int)userInfoRepository.Insert(userInfo);
            }
            else
            {
                return (int)userInfoRepository.Update(userInfo);
            }
        }

        public List<UserInfo> GetUserInfoList(UserInfoSearch search)
        {
            throw new NotImplementedException();
        }

        public PagedList<UserInfo> QueryUserInfoList(UserInfoSearch search, PageView view)
        {
            return userInfoRepository.QueryUserInfoList(search, view);
        }
    }
}
